package cs423.loadBalancer.core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

import android.widget.Toast;

public class HardwareMonitor implements Runnable{

//	public static volatile double userThrottle = 0.0;
	public int period = 2000;
	public static Timer timer;
	
	
	//create a timer that periodically checks the hardware
	@Override
	public void run() {
        timer = new Timer();
        timer.scheduleAtFixedRate(new gatherInfo(), 0, period);
        System.out.println("TIMER IN HARDWARE CREATED SUCCESSFULLY");
	}
	
	class gatherInfo extends TimerTask{

		@Override
		public void run() {
			//get infomation
			//and write to the shared global variable
			
			float cpuUtil = Util.getCpu();
			Main.cpu_usage = cpuUtil;
			
			Main.monitor_w_adaptor.release();
		}
		
	}
	
	
}
